<?php

namespace app\teacher\controller\say;

use app\common\controller\Frontend;
use app\common\model\banxi\say\SayCognitiveCourse as SayCognitiveCourseModel;

class SayCognitiveCourse extends Frontend
{
    protected array $noNeedLogin = [];

    protected array $noNeedPermission = ['*'];

    public function initialize(): void
    {
        parent::initialize();
    }

    public function listCognitiveCourse()
    {
        $categoryId = $this->request->param('categoryId');
        if (!$categoryId) {
            $this->ok('ok', []);
        }
        $where = [
            ['sayCategoryId', '=', $categoryId],
            ['status', '=', 1],
        ];
        $sayTeachSentenceModel = new SayCognitiveCourseModel();
        $list = $sayTeachSentenceModel->with([
            'categoryInfo' => function ($query) {
                $query->field('id,name');
            }])->where($where)->select();
        $this->ok('ok', $list);
    }
}